<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Flutter 布局相关 | 青山依旧的网络日记</title>
    <meta name="description" content="记录web前端那些事">
    <link rel="stylesheet" href="/note/assets/style.44cf3921.css">
    <link rel="modulepreload" href="/note/assets/chunks/VPAlgoliaSearchBox.e8a13dea.js">
    <link rel="modulepreload" href="/note/assets/chunks/ui-custom.8a747abb.js">
    <link rel="modulepreload" href="/note/assets/app.6518bc14.js">
    <link rel="modulepreload" href="/note/assets/guide_flutter-weiget.md.35457cf1.lean.js">
    
    <meta name="keywords" content="jsdawn,青山依旧,网络日记,笔记,web前端,js,vue,vite">
  <link rel="icon" href="/note/logo.svg">
  <script>(()=>{const e=localStorage.getItem("vitepress-theme-appearance"),a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-c66ff1de><!--[--><!--]--><!--[--><span tabindex="-1" data-v-954d4690></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-954d4690> Skip to content </a><!--]--><!----><header class="VPNav" data-v-c66ff1de data-v-f9fa4498><div class="VPNavBar has-sidebar" data-v-f9fa4498 data-v-d7d748c2><div class="container" data-v-d7d748c2><div class="VPNavBarTitle has-sidebar" data-v-d7d748c2 data-v-01b9aac6><a class="title" href="/note/" data-v-01b9aac6><!--[--><img class="VPImage logo" src="/note/logo.svg" data-v-67b84fc0><!--]--><!--[-->青山依旧的网络日记<!--]--></a></div><div class="content" data-v-d7d748c2><div class="VPNavBarSearch search" data-v-d7d748c2><div id="docsearch"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg class="DocSearch-Search-Icon" width="20" height="20" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key">Meta</kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-d7d748c2 data-v-654db621><span id="main-nav-aria-label" class="visually-hidden" data-v-654db621>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink active" href="/note/guide/vue3-upgrade.html" data-v-654db621 data-v-7561f494 data-v-32407edf><!--[-->前端指南<!--]--><!----></a><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-654db621 data-v-bf49c558><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-bf49c558><span class="text" data-v-bf49c558><!----> 踩坑心得 <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-bf49c558><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-bf49c558><div class="VPMenu" data-v-bf49c558 data-v-0f64c8d2><div class="items" data-v-0f64c8d2><!--[--><!--[--><div class="VPMenuLink" data-v-0f64c8d2 data-v-087d3aaa><a class="VPLink link" href="/note/feelings/el-date-picker.html" data-v-087d3aaa data-v-32407edf><!--[-->Element UI 系列<!--]--><!----></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-0f64c8d2 data-v-087d3aaa><a class="VPLink link" href="/note/feelings/a-upload.html" data-v-087d3aaa data-v-32407edf><!--[-->Ant design vue 系列<!--]--><!----></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-0f64c8d2 data-v-087d3aaa><a class="VPLink link" href="/note/feelings/echarts-wordcloud.html" data-v-087d3aaa data-v-32407edf><!--[-->Echarts 系列<!--]--><!----></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/note/node/git-npm.html" data-v-654db621 data-v-7561f494 data-v-32407edf><!--[-->Git/Node<!--]--><!----></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/note/tale/hexo-create.html" data-v-654db621 data-v-7561f494 data-v-32407edf><!--[-->青山物语<!--]--><!----></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-d7d748c2 data-v-79082d9f><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" aria-label="toggle dark mode" data-v-79082d9f data-v-47f2e383 data-v-9ae3dd98><span class="check" data-v-9ae3dd98><span class="icon" data-v-9ae3dd98><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-47f2e383><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-47f2e383><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-d7d748c2 data-v-6745ff8f data-v-b7a19e6a><!--[--><a class="VPSocialLink" href="https://github.com/jsdawn" title="github" target="_blank" rel="noopener noreferrer" data-v-b7a19e6a data-v-205dd35e><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-205dd35e><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path></svg><span class="visually-hidden" data-v-205dd35e>github</span></a><a class="VPSocialLink" href="https://juejin.cn/user/2101921962267079/posts" title="slack" target="_blank" rel="noopener noreferrer" data-v-b7a19e6a data-v-205dd35e><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-205dd35e><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"></path></svg><span class="visually-hidden" data-v-205dd35e>slack</span></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-d7d748c2 data-v-7bb88228 data-v-bf49c558><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-bf49c558><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-bf49c558><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-bf49c558><div class="VPMenu" data-v-bf49c558 data-v-0f64c8d2><!----><!--[--><!--[--><!----><div class="group" data-v-7bb88228><div class="item appearance" data-v-7bb88228><p class="label" data-v-7bb88228>Appearance</p><div class="appearance-action" data-v-7bb88228><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" aria-label="toggle dark mode" data-v-7bb88228 data-v-47f2e383 data-v-9ae3dd98><span class="check" data-v-9ae3dd98><span class="icon" data-v-9ae3dd98><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-47f2e383><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-47f2e383><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><div class="group" data-v-7bb88228><div class="item social-links" data-v-7bb88228><div class="VPSocialLinks social-links-list" data-v-7bb88228 data-v-b7a19e6a><!--[--><a class="VPSocialLink" href="https://github.com/jsdawn" title="github" target="_blank" rel="noopener noreferrer" data-v-b7a19e6a data-v-205dd35e><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-205dd35e><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path></svg><span class="visually-hidden" data-v-205dd35e>github</span></a><a class="VPSocialLink" href="https://juejin.cn/user/2101921962267079/posts" title="slack" target="_blank" rel="noopener noreferrer" data-v-b7a19e6a data-v-205dd35e><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-205dd35e><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"></path></svg><span class="visually-hidden" data-v-205dd35e>slack</span></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-d7d748c2 data-v-2379f326><span class="container" data-v-2379f326><span class="top" data-v-2379f326></span><span class="middle" data-v-2379f326></span><span class="bottom" data-v-2379f326></span></span></button></div></div></div><!----></header><div class="VPLocalNav" data-v-c66ff1de data-v-2d7b81c3><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-2d7b81c3><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-2d7b81c3><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-2d7b81c3>Menu</span></button><a class="top-link" href="#" data-v-2d7b81c3> Return to top </a></div><aside class="VPSidebar" data-v-c66ff1de data-v-0970777a><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-0970777a><span class="visually-hidden" id="sidebar-aria-label" data-v-0970777a> Sidebar Navigation </span><!--[--><div class="group" data-v-0970777a><section class="VPSidebarGroup collapsible" data-v-0970777a data-v-5973b055><div class="title" role="button" data-v-5973b055><h2 class="title-text" data-v-5973b055>前端指南</h2><div class="action" data-v-5973b055><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-5973b055><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-5973b055><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-5973b055><!--[--><a class="VPLink link" href="/note/guide/vue3-upgrade.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Vue3.0 项目升级到 Vue3.2</span><!--]--><!----></a><a class="VPLink link" href="/note/guide/vue3-tinymce.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Vue3 富文本编辑器</span><!--]--><!----></a><a class="VPLink link" href="/note/guide/vue3-i18n.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>vue3 国际化(i18n)</span><!--]--><!----></a><a class="VPLink link" href="/note/guide/flutter-mall.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Flutter 2 商城App实战指南</span><!--]--><!----></a><a class="VPLink link active" href="/note/guide/flutter-weiget.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Flutter 布局相关</span><!--]--><!----></a><a class="VPLink link" href="/note/guide/flutter-const.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Flutter 语法相关</span><!--]--><!----></a><a class="VPLink link" href="/note/guide/docker-compose.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Docker 部署 Node 项目</span><!--]--><!----></a><a class="VPLink link" href="/note/guide/docker-github.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Docker GitHub 集成工作流</span><!--]--><!----></a><!--]--></div></section></div><div class="group" data-v-0970777a><section class="VPSidebarGroup collapsible" data-v-0970777a data-v-5973b055><div class="title" role="button" data-v-5973b055><h2 class="title-text" data-v-5973b055>踩坑心得</h2><div class="action" data-v-5973b055><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-5973b055><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-5973b055><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-5973b055><!--[--><a class="VPLink link" href="/note/feelings/vue3-waterfall-flow.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Vue3 瀑布流列表组件封装</span><!--]--><!----></a><a class="VPLink link" href="/note/feelings/js-lazy-load.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>JS 图片懒加载</span><!--]--><!----></a><a class="VPLink link" href="/note/feelings/el-date-picker.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Element 日期组件范围选择</span><!--]--><!----></a><a class="VPLink link" href="/note/feelings/a-upload.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Antd vue Upload 自定义上传</span><!--]--><!----></a><a class="VPLink link" href="/note/feelings/echarts-wordcloud.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Echarts 词云图</span><!--]--><!----></a><!--]--></div></section></div><div class="group" data-v-0970777a><section class="VPSidebarGroup collapsible" data-v-0970777a data-v-5973b055><div class="title" role="button" data-v-5973b055><h2 class="title-text" data-v-5973b055>Git / Node / Npm</h2><div class="action" data-v-5973b055><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-5973b055><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-5973b055><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-5973b055><!--[--><a class="VPLink link" href="/note/node/git-npm.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Git &amp; Npm 常用指令</span><!--]--><!----></a><!--]--></div></section></div><div class="group" data-v-0970777a><section class="VPSidebarGroup collapsible" data-v-0970777a data-v-5973b055><div class="title" role="button" data-v-5973b055><h2 class="title-text" data-v-5973b055>青山物语</h2><div class="action" data-v-5973b055><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 24 24" class="icon minus" data-v-5973b055><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2zM20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h8c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg><svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon plus" data-v-5973b055><path d="M19,2H5C3.3,2,2,3.3,2,5v14c0,1.7,1.3,3,3,3h14c1.7,0,3-1.3,3-3V5C22,3.3,20.7,2,19,2z M20,19c0,0.6-0.4,1-1,1H5c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h14c0.6,0,1,0.4,1,1V19z"></path><path d="M16,11h-3V8c0-0.6-0.4-1-1-1s-1,0.4-1,1v3H8c-0.6,0-1,0.4-1,1s0.4,1,1,1h3v3c0,0.6,0.4,1,1,1s1-0.4,1-1v-3h3c0.6,0,1-0.4,1-1S16.6,11,16,11z"></path></svg></div></div><div class="items" data-v-5973b055><!--[--><a class="VPLink link" href="/note/tale/hualang.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>🏞 青山画廊</span><!--]--><!----></a><a class="VPLink link" href="/note/tale/hexo-create.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>Hexo 博客搭建简易教程</span><!--]--><!----></a><a class="VPLink link" href="/note/tale/p1-zongjie.html" data-v-5973b055 data-v-ded4328e data-v-32407edf><!--[--><span class="link-text" data-v-ded4328e>P1 攻城狮的江湖总结</span><!--]--><!----></a><!--]--></div></section></div><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-c66ff1de data-v-580a4f65><div class="VPDoc has-sidebar" data-v-580a4f65 data-v-594e0a10><div class="container" data-v-594e0a10><div class="aside" data-v-594e0a10><div class="aside-curtain" data-v-594e0a10></div><div class="aside-container" data-v-594e0a10><div class="aside-content" data-v-594e0a10><div class="VPDocAside" data-v-594e0a10 data-v-6d380436><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline has-outline" data-v-6d380436 data-v-55303134><div class="content" data-v-55303134><div class="outline-marker" data-v-55303134></div><div class="outline-title" data-v-55303134>﹌﹋文章目录﹋﹌</div><nav aria-labelledby="doc-outline-aria-label" data-v-55303134><span class="visually-hidden" id="doc-outline-aria-label" data-v-55303134> Table of Contents for current page </span><ul class="root" data-v-55303134><!--[--><li style="" data-v-55303134><a class="outline-link" href="#盒约束-boxconstraints" data-v-55303134>盒约束 BoxConstraints</a><!----></li><li style="" data-v-55303134><a class="outline-link" href="#常用基础-widget" data-v-55303134>常用基础 Widget</a><!----></li><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-6d380436></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-594e0a10><div class="content-container" data-v-594e0a10><!--[--><!--]--><main class="main" data-v-594e0a10><div style="position:relative;" class="vp-doc _note_guide_flutter-weiget" data-v-594e0a10><div><h1 id="flutter-布局小部件" tabindex="-1">Flutter 布局小部件 <a class="header-anchor" href="#flutter-布局小部件" aria-hidden="true">#</a></h1><blockquote><p>文章简单描述 flutter 布局常用 Widget 和 相关知识点，便于开发过程中查阅</p></blockquote><h2 id="盒约束-boxconstraints" tabindex="-1">盒约束 BoxConstraints <a class="header-anchor" href="#盒约束-boxconstraints" aria-hidden="true">#</a></h2><p><code>约束</code>是父级渲染对象对子级渲染对象的尺寸限制。 widget只有在 松约束或无约束的父元素下才可自由改变尺寸。</p><p>通过 <code>flutter inspector - detail Tree</code> 面板里 widget 下的 <code>renderObject.constraints</code> 查看该 widget 的约束情况</p><ul><li>紧约束下设置尺寸无效</li><li>UnconstrainedBox 解除约束，自身无约束，不约束子级</li><li>Flex 、 Column、Row、 Wrap 、Stack 放松约束：0~最大</li><li>CustomSingleChildLayout 自定义新约束</li><li>Flexible 默认 <code>fit: FlexFit.loose</code> 松约束， Expanded 为 <code>fit: FlexFit.tight</code> 紧约束</li></ul><h2 id="常用基础-widget" tabindex="-1">常用基础 Widget <a class="header-anchor" href="#常用基础-widget" aria-hidden="true">#</a></h2><h3 id="statefulwidget-与-statelesswidget" tabindex="-1">StatefulWidget 与 StatelessWidget <a class="header-anchor" href="#statefulwidget-与-statelesswidget" aria-hidden="true">#</a></h3><ul><li><p><code>StatefulWidget</code>： 状态部件，持有的状态可能在widget生命周期中发生变化。当widget的状态发生变化时，widget会重新构建UI。 实现一个 stateful widget 至少需要两个类：</p><ol><li>一个 <code>StatefulWidget</code> 类。</li><li>一个 <code>State</code> 类。 StatefulWidget类本身是不变的，但是 State类在widget生命周期中始终存在.</li></ol></li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;">class</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Stful</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">extends</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">StatefulWidget</span><span style="color:#A6ACCD;"> {</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Stful</span><span style="color:#A6ACCD;">({</span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key}) </span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> super(key</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> key)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">@override</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">State</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Stful</span><span style="color:#A6ACCD;">&gt; </span><span style="color:#82AAFF;">createState</span><span style="color:#A6ACCD;">() </span><span style="color:#89DDFF;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">_StfulState</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#89DDFF;">class</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">_StfulState</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">extends</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">State</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Stful</span><span style="color:#A6ACCD;">&gt; {</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">@override</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">build</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">BuildContext</span><span style="color:#A6ACCD;"> context) {</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Container</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">  }</span></span>
<span class="line"><span style="color:#A6ACCD;">}</span></span>
<span class="line"></span></code></pre></div><ul><li><code>StatelessWidget</code>：状态是不可变的, 这意味着它们的属性不能改变 - 所有的值都是最终的。</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;">class</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Stless</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">extends</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">StatelessWidget</span><span style="color:#A6ACCD;"> {</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Stless</span><span style="color:#A6ACCD;">({</span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key}) </span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> super(key</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> key)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">@override</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">build</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">BuildContext</span><span style="color:#A6ACCD;"> context) {</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Container</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">  }</span></span>
<span class="line"><span style="color:#A6ACCD;">}</span></span>
<span class="line"></span></code></pre></div><h3 id="text-文本" tabindex="-1">Text 文本 <a class="header-anchor" href="#text-文本" aria-hidden="true">#</a></h3><ul><li><code>Text</code>：创建一个带格式的文本。</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">Text</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">String</span><span style="color:#A6ACCD;"> data</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> {</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextStyle</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> style</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 文字样式</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">StrutStyle</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> strutStyle</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextAlign</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textAlign</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 文字对齐方式</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextDirection</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textDirection</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 文字方向</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Locale</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> locale</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> softWrap</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 是否换行，默认true</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextOverflow</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> overflow</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 越界效果</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textScaleFactor</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">int</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> maxLines</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 最大行数</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">String</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> semanticsLabel</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextWidthBasis</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textWidthBasis</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextHeightBehavior</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textHeightBehavior</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span></code></pre></div><h3 id="flex-布局" tabindex="-1">Flex 布局 <a class="header-anchor" href="#flex-布局" aria-hidden="true">#</a></h3><ul><li><code>Flex</code> 弹性布局</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">Flex</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 排列方向，水平 horizontal/垂直 vertical</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">required</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Axis</span><span style="color:#A6ACCD;"> direction</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 主轴对齐方式</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">MainAxisAlignment</span><span style="color:#A6ACCD;"> mainAxisAlignment </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MainAxisAlignment</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">start</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 主轴尺寸</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">MainAxisSize</span><span style="color:#A6ACCD;"> mainAxisSize </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MainAxisSize</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">max</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 交叉轴对齐方式</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">CrossAxisAlignment</span><span style="color:#A6ACCD;"> crossAxisAlignment </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">CrossAxisAlignment</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">center</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 水平时排布方向 ltr/rtl</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextDirection</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textDirection</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 垂直时排布方向 down/up</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">VerticalDirection</span><span style="color:#A6ACCD;"> verticalDirection </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">VerticalDirection</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">down</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// CrossAxisAlignment.baseline 时 TextBaseline基线类型</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextBaseline</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textBaseline</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Clip</span><span style="color:#A6ACCD;"> clipBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Clip</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">none</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// widget列表</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">List</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;">&gt; children </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">[]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span></code></pre></div><ul><li><code>Row</code>、<code>Column</code>：水平（Row）垂直（Column）的<code>Flex</code>布局。</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">Row</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// 主轴对齐方式</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">MainAxisAlignment</span><span style="color:#A6ACCD;"> mainAxisAlignment </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MainAxisAlignment</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">start</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// 主轴尺寸</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">MainAxisSize</span><span style="color:#A6ACCD;"> mainAxisSize </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MainAxisSize</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">max</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// 交叉轴对齐方式</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">CrossAxisAlignment</span><span style="color:#A6ACCD;"> crossAxisAlignment </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">CrossAxisAlignment</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">center</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// 排列方向、ltr 从左到右（默认）、rtl 从右到左</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">TextDirection</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textDirection</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// 垂直方向</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">VerticalDirection</span><span style="color:#A6ACCD;"> verticalDirection </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">VerticalDirection</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">down</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// 文本基线</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">TextBaseline</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textBaseline</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// widget列表</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">List</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;">&gt; children </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">[]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// 例：Column的属性与Row基本一致</span></span>
<span class="line"><span style="color:#FFCB6B;">Column</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">MainAxisAlignment</span><span style="color:#A6ACCD;"> mainAxisAlignment </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MainAxisAlignment</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">start</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">MainAxisSize</span><span style="color:#A6ACCD;"> mainAxisSize </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MainAxisSize</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">max</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">CrossAxisAlignment</span><span style="color:#A6ACCD;"> crossAxisAlignment </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">CrossAxisAlignment</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">center</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// 排列方向、ltr 从上到下（默认）、rtl 从下到上</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">TextDirection</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textDirection</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">VerticalDirection</span><span style="color:#A6ACCD;"> verticalDirection </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">VerticalDirection</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">down</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">TextBaseline</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textBaseline</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">List</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;">&gt; children </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">[]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span></code></pre></div><h3 id="stack、positioned-堆叠与定位" tabindex="-1">Stack、Positioned 堆叠与定位 <a class="header-anchor" href="#stack、positioned-堆叠与定位" aria-hidden="true">#</a></h3><ul><li><code>Stack</code>：堆叠布局，运行子widget堆叠，使用<code>Positioned</code>定位相对于<code>Stack</code> 边框的位置。（Web中的绝对定位布局 <code>absolute</code>）</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">Stack</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 对齐方式</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">AlignmentGeometry</span><span style="color:#A6ACCD;"> alignment </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">AlignmentDirectional</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">topStart</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 文字排布方向</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TextDirection</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> textDirection</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 适应方式</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">StackFit</span><span style="color:#A6ACCD;"> fit </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">StackFit</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">loose</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 溢出模式</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Overflow</span><span style="color:#A6ACCD;"> overflow </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Overflow</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">clip</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Clip</span><span style="color:#A6ACCD;"> clipBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Clip</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">hardEdge</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// widget列表</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">List</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;">&gt; children </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">[]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">Positioned</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> left</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> top</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> right</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> bottom</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> width</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> height</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">required</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;"> child</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// 例：Stack 与 Positioned 配合</span></span>
<span class="line"><span style="color:#FFCB6B;">Stack</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// topRight - children里的widget布局在右上角 </span></span>
<span class="line"><span style="color:#A6ACCD;">  alignment</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Alignment</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">topRight</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  children</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> [</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">Container</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">      color</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Colors</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">red</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      width</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">100</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      height</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">100</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    )</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">Container</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">      color</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Colors</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">blue</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      width</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">80</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      height</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">80</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    )</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// Positioned 设置独立的绝对定位</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">Positioned</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">      bottom</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">20</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      left</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">20</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      child</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Container</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">        color</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Colors</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">blue</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">        width</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">70</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">        height</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">70</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      )</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    )</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  ]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">)</span></span>
<span class="line"></span></code></pre></div><h3 id="container-容器" tabindex="-1">Container 容器 <a class="header-anchor" href="#container-容器" aria-hidden="true">#</a></h3><ul><li><code>Container</code>：创建块级元素（web的块级元素 <code>div</code>）</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">Container</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">AlignmentGeometry</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> alignment</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 对齐方式</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">EdgeInsetsGeometry</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> padding</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 内边距</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Color</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> color</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 背景颜色</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 装饰：border/radius/gradient/boxshadow/image</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Decoration</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> decoration</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Decoration</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> foregroundDecoration</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> width</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> height</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">BoxConstraints</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> constraints</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">EdgeInsetsGeometry</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> margin</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 外边距</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Matrix4</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> transform</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 转换</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">AlignmentGeometry</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> transformAlignment</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> child</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 子widget</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Clip</span><span style="color:#A6ACCD;"> clipBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Clip</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">none</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span></code></pre></div><h3 id="singlechildscrollview-滑动容器" tabindex="-1">SingleChildScrollView 滑动容器 <a class="header-anchor" href="#singlechildscrollview-滑动容器" aria-hidden="true">#</a></h3><ul><li><code>SingleChildScrollView</code> 使包裹的组件可滑动</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">SingleChildScrollView</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 滑动方向</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Axis</span><span style="color:#A6ACCD;"> scrollDirection </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Axis</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">vertical</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 是否反向</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> reverse </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">false,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 容器内边距</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">EdgeInsetsGeometry</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> padding</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> primary</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">ScrollPhysics</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> physics</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">ScrollController</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> controller</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 子组件 Widget</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> child</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">DragStartBehavior</span><span style="color:#A6ACCD;"> dragStartBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">DragStartBehavior</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">start</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Clip</span><span style="color:#A6ACCD;"> clipBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Clip</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">hardEdge</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">String</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> restorationId</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">ScrollViewKeyboardDismissBehavior</span><span style="color:#A6ACCD;"> keyboardDismissBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">ScrollViewKeyboardDismissBehavior</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">manual</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span></code></pre></div><h3 id="listview-列表容器" tabindex="-1">ListView 列表容器 <a class="header-anchor" href="#listview-列表容器" aria-hidden="true">#</a></h3><ul><li><code>ListView</code>：用于显示多个子Widget的可滑动容器</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">ListView</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 滑动方向</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Axis</span><span style="color:#A6ACCD;"> scrollDirection </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Axis</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">vertical</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 是否反向</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> reverse </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">false,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 控制器</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">ScrollController</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> controller</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> primary</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">ScrollPhysics</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> physics</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> shrinkWrap </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">false,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 容器内边距</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">EdgeInsetsGeometry</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> padding</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> itemExtent</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> prototypeItem</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> addAutomaticKeepAlives </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">true,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> addRepaintBoundaries </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">true,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> addSemanticIndexes </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">true,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">double</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> cacheExtent</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// Widget 列表</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">List</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;">&gt; children </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">[]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">int</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> semanticChildCount</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">DragStartBehavior</span><span style="color:#A6ACCD;"> dragStartBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">DragStartBehavior</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">start</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">ScrollViewKeyboardDismissBehavior</span><span style="color:#A6ACCD;"> keyboardDismissBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">ScrollViewKeyboardDismissBehavior</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">manual</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">String</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> restorationId</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Clip</span><span style="color:#A6ACCD;"> clipBehavior </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Clip</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">hardEdge</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span></code></pre></div><ul><li><code>ListView.builder</code>：ListView item构造器，较<code>ListView</code>新增了<code>itemBuilder</code>和<code>itemCount</code>属性，常用于创建子组件类似的列表</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">ListView</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">builder</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 子组件构造器，传参上下文和索引index</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">required</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">BuildContext</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">int</span><span style="color:#A6ACCD;">) itemBuilder</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 子组件数量</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">int</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> itemCount</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// 例：</span></span>
<span class="line"><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">_itemBuilder</span><span style="color:#A6ACCD;">(context</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> index) {</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">SizedBox</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">      height</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">100</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      child</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Text</span><span style="color:#A6ACCD;">(index</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">toString</span><span style="color:#A6ACCD;">())</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    )</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">  }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">ListView</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">builder</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">      itemBuilder</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> _itemBuilder</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      itemCount</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">20</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    )</span></span>
<span class="line"></span></code></pre></div><ul><li><code>ListView.separated</code>：ListView 分隔构造器，较<code>ListView</code>新增了<code>itemBuilder</code>、<code>separatorBuilder</code>和<code>itemCount</code>属性，常用于创建子组件类似且带分割块的列表</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">ListView</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">separated</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 子组件构造器，传参上下文和索引index</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">required</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">BuildContext</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">int</span><span style="color:#A6ACCD;">) itemBuilder</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 分割区域构造器，该条目不计入子组件数量</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">required</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">BuildContext</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">int</span><span style="color:#A6ACCD;">) separatorBuilder</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 子组件数量</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">int</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> itemCount</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// 例：</span></span>
<span class="line"><span style="color:#FFCB6B;">Widget</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">_separatorBuilder</span><span style="color:#A6ACCD;">(context</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> index) {</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Divider</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">      height</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      color</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Colors</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">black</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    )</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">  }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">ListView</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">separated</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">      itemBuilder</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> _itemBuilder</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      separatorBuilder</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> _separatorBuilder</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      itemCount</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">20</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    )</span></span>
<span class="line"></span></code></pre></div><h3 id="gesturedetector-手势" tabindex="-1">GestureDetector 手势 <a class="header-anchor" href="#gesturedetector-手势" aria-hidden="true">#</a></h3><ul><li><code>GestureDetector</code>：处理手势（web中<code>onClick</code>事件等）</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#676E95;font-style:italic;">// GestureDetector 类有很多属性，列出较常用的几个</span></span>
<span class="line"><span style="color:#FFCB6B;">GestureDetector</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Widget</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> child</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">void</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> onTap</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 点击事件</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">void</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> onDoubleTap</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 双击事件</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#C792EA;">void</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> onLongPress</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// 长按事件</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// 例：</span></span>
<span class="line"><span style="color:#FFCB6B;">GestureDetector</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">  onTap</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> () </span><span style="color:#89DDFF;">=&gt;</span><span style="color:#A6ACCD;"> {}</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  onDoubleTap</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> () </span><span style="color:#89DDFF;">=&gt;</span><span style="color:#A6ACCD;"> {}</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  onLongPress</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> () </span><span style="color:#89DDFF;">=&gt;</span><span style="color:#A6ACCD;"> {}</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  child</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">SizedBox</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">    width</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">100</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    height</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">100</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  )</span></span>
<span class="line"><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h3 id="路由导航器" tabindex="-1">路由导航器 <a class="header-anchor" href="#路由导航器" aria-hidden="true">#</a></h3><ul><li><code>Navigator</code> 导航器组件</li></ul><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#FFCB6B;">Navigator</span><span style="color:#A6ACCD;">({</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Key</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> key</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">List</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Page</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;&gt; pages </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#FFCB6B;">Page</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;&gt;[]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 出栈(back)回调</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> onPopPage</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 初始显示路由</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">String</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> initialRoute</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">List</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;&gt; </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">NavigatorState</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">String</span><span style="color:#A6ACCD;">) onGenerateInitialRoutes </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Navigator</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">defaultGenerateInitialRoutes</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 路由生成器</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">RouteSettings</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> onGenerateRoute</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Function</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">RouteSettings</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> onUnknownRoute</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">TransitionDelegate</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt; transitionDelegate </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">DefaultTransitionDelegate</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;()</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> reportsRouteUpdateToEngine </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">false,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">// 路由监听器</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">List</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">NavigatorObserver</span><span style="color:#A6ACCD;">&gt; observers </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#FFCB6B;">NavigatorObserver</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">[]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">bool</span><span style="color:#A6ACCD;"> requestFocus </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">true,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">String</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> restorationScopeId</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">})</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// 例：</span></span>
<span class="line"><span style="color:#FFCB6B;">Navigator</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">        onPopPage</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> _onPopPageBack</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">        initialRoute</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">&#39;/home-content&#39;</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">        onGenerateRoute</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> _onGenerateRoute</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">        observers</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> [</span><span style="color:#FFCB6B;">_NavigatorObserver</span><span style="color:#A6ACCD;">()]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">      )</span></span>
<span class="line"><span style="color:#A6ACCD;">   </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/*   </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// `MaterialApp`集成了`Navigator`部分核心属性，所以路由部分可直接写到MaterialApp</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">MaterialApp(</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">    theme: ThemeData(</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">        primaryColor: Colors.blue,</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">    ),</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">    home: _HomePage,</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">    initialRoute: &#39;/home-content&#39;,</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">    onGenerateRoute: _onGenerateRoute,</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">    navigatorObservers: [_NavigatorObserver()],</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">)</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">*/</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span></span>
<span class="line"><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">_onGenerateRoute</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">RouteSettings</span><span style="color:#A6ACCD;"> settings) {</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;font-style:italic;">switch</span><span style="color:#A6ACCD;"> (settings</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">name) {</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;font-style:italic;">case</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">&#39;/home-content&#39;</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MaterialPageRoute</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">            builder</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> (_) </span><span style="color:#89DDFF;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">HomeContent</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> settings</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> settings)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;font-style:italic;">case</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">&quot;/my-conetent&quot;</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MaterialPageRoute</span><span style="color:#A6ACCD;">(builder</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> (_) </span><span style="color:#89DDFF;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Mycontent</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> settings</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> settings)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;font-style:italic;">default</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MaterialPageRoute</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">            builder</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> (_) </span><span style="color:#89DDFF;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">HomeContent</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> settings</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> settings)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">    }</span></span>
<span class="line"><span style="color:#A6ACCD;">  }</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">//路由监听器</span></span>
<span class="line"><span style="color:#89DDFF;">class</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">_NavigatorObserver</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">extends</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">NavigatorObserver</span><span style="color:#A6ACCD;"> {</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#C792EA;">@override</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#C792EA;">void</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">didPush</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt; route</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> previousRoute) {</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#82AAFF;">print</span><span style="color:#A6ACCD;">(`${route</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">settings}`)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">    }</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#C792EA;">@override</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#C792EA;">void</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">didPop</span><span style="color:#A6ACCD;">(</span><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt; route</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Route</span><span style="color:#A6ACCD;">&lt;</span><span style="color:#FFCB6B;">dynamic</span><span style="color:#A6ACCD;">&gt;</span><span style="color:#89DDFF;">?</span><span style="color:#A6ACCD;"> previousRoute) {</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#82AAFF;">print</span><span style="color:#A6ACCD;">(`${route</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">settings}`)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">    }</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">// 更多监听事件查看 `NavigatorObserver` 类</span></span>
<span class="line"><span style="color:#A6ACCD;">}</span></span>
<span class="line"></span></code></pre></div><div class="language-dart"><span class="copy"></span><pre><code><span class="line"><span style="color:#676E95;font-style:italic;">// 路由跳转</span></span>
<span class="line"><span style="color:#FFCB6B;">Navigator</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">of</span><span style="color:#A6ACCD;">(context)</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">pushNamed</span><span style="color:#A6ACCD;">(routeName)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// 直接跳转页面控件</span></span>
<span class="line"><span style="color:#FFCB6B;">Navigator</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">of</span><span style="color:#A6ACCD;">(context)</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">push</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">MaterialPageRoute</span><span style="color:#A6ACCD;">(</span></span>
<span class="line"><span style="color:#A6ACCD;">        builder</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> (</span><span style="color:#FFCB6B;">BuildContext</span><span style="color:#A6ACCD;"> context) </span><span style="color:#89DDFF;">=&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">MyPage</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">    )</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// 出栈（返回上一页）</span></span>
<span class="line"><span style="color:#FFCB6B;">Navigator</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">of</span><span style="color:#A6ACCD;">(context)</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">pop</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><blockquote><p><strong>转载声明</strong>： 请注明作者，注明原文链接，有疑问致邮 <a href="mailto:kingwyh1993@163.com">kingwyh1993@163.com</a></p></blockquote></div></div></main><footer class="VPDocFooter" data-v-594e0a10 data-v-a2c60774><div class="edit-info" data-v-a2c60774><div class="edit-link" data-v-a2c60774><a class="VPLink link edit-link-button" href="https://github.com/jsdawn/note/edit/master/docs/guide/flutter-weiget.md" target="_blank" rel="noopener noreferrer" data-v-a2c60774 data-v-32407edf><!--[--><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="edit-link-icon" data-v-a2c60774><path d="M18,23H4c-1.7,0-3-1.3-3-3V6c0-1.7,1.3-3,3-3h7c0.6,0,1,0.4,1,1s-0.4,1-1,1H4C3.4,5,3,5.4,3,6v14c0,0.6,0.4,1,1,1h14c0.6,0,1-0.4,1-1v-7c0-0.6,0.4-1,1-1s1,0.4,1,1v7C21,21.7,19.7,23,18,23z"></path><path d="M8,17c-0.3,0-0.5-0.1-0.7-0.3C7,16.5,6.9,16.1,7,15.8l1-4c0-0.2,0.1-0.3,0.3-0.5l9.5-9.5c1.2-1.2,3.2-1.2,4.4,0c1.2,1.2,1.2,3.2,0,4.4l-9.5,9.5c-0.1,0.1-0.3,0.2-0.5,0.3l-4,1C8.2,17,8.1,17,8,17zM9.9,12.5l-0.5,2.1l2.1-0.5l9.3-9.3c0.4-0.4,0.4-1.1,0-1.6c-0.4-0.4-1.2-0.4-1.6,0l0,0L9.9,12.5z M18.5,2.5L18.5,2.5L18.5,2.5z"></path></svg> Edit this page on github<!--]--><!----></a></div><div class="last-updated" data-v-a2c60774><p class="VPLastUpdated" data-v-a2c60774 data-v-16d7c010>Updated Date: <time datatime="2022-07-27T04:06:36.000Z" data-v-16d7c010></time></p></div></div><div class="prev-next" data-v-a2c60774><div class="pager" data-v-a2c60774><a class="pager-link prev" href="/note/guide/flutter-mall.html" data-v-a2c60774><span class="desc" data-v-a2c60774>Previous page</span><span class="title" data-v-a2c60774>Flutter 2 商城App实战指南</span></a></div><div class="has-prev pager" data-v-a2c60774><a class="pager-link next" href="/note/guide/flutter-const.html" data-v-a2c60774><span class="desc" data-v-a2c60774>Next page</span><span class="title" data-v-a2c60774>Flutter 语法相关</span></a></div></div></footer><!--[--><!--]--></div></div></div></div></div><footer class="VPFooter has-sidebar" data-v-c66ff1de data-v-758a7cec><div class="container" data-v-758a7cec><p class="message" data-v-758a7cec>Released under the Apache License 2.0 License.</p><p class="copyright" data-v-758a7cec>Copyright © 2022-present 青山依旧</p></div></footer><!--[--><!--]--></div></div>
    <script>__VP_HASH_MAP__ = JSON.parse("{\"components_index.md\":\"c71eaabc\",\"feelings_a-upload.md\":\"c24f19c1\",\"feelings_echarts-wordcloud.md\":\"49f7ba66\",\"feelings_el-date-picker.md\":\"f1052dce\",\"feelings_js-lazy-load.md\":\"866a6573\",\"feelings_vue3-waterfall-flow.md\":\"d38323f6\",\"guide_docker-compose.md\":\"61ab6185\",\"guide_docker-github.md\":\"38b70b85\",\"guide_flutter-const.md\":\"db61f59e\",\"guide_flutter-mall.md\":\"053d420a\",\"guide_flutter-weiget.md\":\"35457cf1\",\"guide_vue3-i18n.md\":\"ef8b8776\",\"guide_vue3-tinymce.md\":\"d6c4784e\",\"guide_vue3-upgrade.md\":\"c0d0a296\",\"index.md\":\"42f45fbc\",\"node_git-npm.md\":\"94662dbd\",\"tale_hexo-create.md\":\"9496a4e9\",\"tale_hualang.md\":\"3079cb8f\",\"tale_p1-zongjie.md\":\"50509583\",\"widgets_index.md\":\"f7612fd9\"}")</script>
    <script type="module" async src="/note/assets/app.6518bc14.js"></script>
    
  </body>
</html>